<?php
// namespace demo;
/**
 *
 * @authors  Ysg (y.shi.guo@gmail.com)
 * @website  http://ysg.bonza.cn
 * @date     2017-07-24 11:43:02
 */

header("Content-type:text/html;charset:utf8;");
header("Pragma: no-cache");
header("Pragma: no-cache");

date_default_timezone_set('PRC');

define("ROOT_PATH",realpath('.'));

class A
{
	static private $instance = NULL;

	private function __construct()
	{

	}
	//单例模式
/*	static public function getInstance()
	{
		if (!(self::$instance instanceof self)) {
			self::$instance = new self;
		}
		return self::$instance;
	}*/
	//单例模式第二种实现方式
	static public function getInstance()
	{
		if (empty(self::$instance)) {
			self::$instance = new self;
		}
		return self::$instance;
	}

	public function say()
	{
		echo "string";
	}
}
// $a = new A();
// var_dump(A::getInstance());


$a = (A::getInstance());

$a->say();















